package com.woniuxy.springmvcparam.interceptor;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author linke
 * @version 1.0
 * @className: MySecondInterceptor
 * @description: 继承HandlerInterceptorAdapter方式的 拦截器
 * @date 2021/11/14 11:03
 */
@Component
public class MySecondInterceptor extends HandlerInterceptorAdapter {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

        System.out.println("我是MySecondInterceptor 的preHandle()");
        return super.preHandle(request, response, handler);
    }

    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
        System.out.println("我是MySecondInterceptor postHandle()");
        super.postHandle(request, response, handler, modelAndView);
    }

    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
        System.out.println("我是MySecondInterceptor afterCompletion()");
        super.afterCompletion(request, response, handler, ex);
    }
}
